package com.cctv.haierstore.search.controller;

import com.cctv.common.exception.BizCodeEnume;
import com.cctv.common.to.es.SkuEsModel;
import com.cctv.common.utils.R;
import com.cctv.haierstore.search.service.ProductSaveService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * @author huayi
 * @date 2023年11月26日 23:04
 */
@Slf4j
@RequestMapping("/search/save")
@RestController
public class ElasticSaveController {

    @Autowired
    ProductSaveService productSaveService;

    @PostMapping("/product")
    public R productStatusUp(@RequestBody List<SkuEsModel> skuEsModels) {
        Boolean b = false;
        try {
            b = productSaveService.productStatusUp(skuEsModels);
        } catch (Exception e) {
            log.error("ElasticSearch商品上架错误:{}", e);
            return R.error(BizCodeEnume.PRODUCT_UP_EXCEPTION.getCode(), BizCodeEnume.PRODUCT_UP_EXCEPTION.getMsg());
        }
        return R.ok();
    }

//    @GetMapping(value = {"/","/list.html"})
//    public String index(){
//        System.out.println(111);
//        return "index";
//    }

}
